package com.broheim.websocket.server;

import com.broheim.websocket.core.event.accept.Event;
import com.broheim.websocket.core.event.accept.OnMessageEvent;
import com.broheim.websocket.core.listener.Listener;
import com.broheim.websocket.core.listener.ListenerChain;

public class SimpleMessageListener implements Listener {
    @Override
    public void onEvent(Event event, ListenerChain chain) throws Exception {
        if (event instanceof OnMessageEvent) {
            System.out.println("accept message is " + ((OnMessageEvent) event).getMessage());
            ((OnMessageEvent) event).getChannelContext().sendText(((OnMessageEvent) event).getMessage());
        }
    }
}
